package main

import (
	"fmt"

	"gitlab.upchinaproduct.com/taf/tafgo/taf"

	"dataconvertserver/taf-protocol/CRM"
)

func main() {
	//SendKeyTellMe()
	SendSqlExecute()
}

func SendKeyTellMe() {
	comm := taf.NewCommunicator()
	obj := fmt.Sprintf("CRM.DataConvertServer.DataConvertObj@tcp -h 127.0.0.1 -p 10015 -t 60000")
	app := new(CRM.DataConvert)
	comm.StringToProxy(obj, app)

	var req CRM.SendKeyTellMeReq
	var rsp CRM.SendKeyTellMeRsp
	var ret, err = app.SendKeyTellMe(&req, &rsp)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("ret: %d, rsp: %+v\n", ret, rsp)
}

func SendSqlExecute() {
	comm := taf.NewCommunicator()
	obj := fmt.Sprintf("CRM.DataConvertServer.DataConvertObj@tcp -h 127.0.0.1 -p 10015 -t 60000")
	app := new(CRM.DataConvert)
	comm.StringToProxy(obj, app)

	var req CRM.SendSqlExecuteReq
	var rsp CRM.SendSqlExecuteRsp
	req.Statement = "select"
	req.ExplainSql = "select * from db_test.t_user_center_user;"
	//req.ExplainSql = "insert into db_test.t_user_center_user(uid,`name`,sign,img,gender,area_code,phone,update_time,cache_key) values('6','用户_6',null,null,'0'\n,'+86','13971612352',from_unixtime(1712822858),'User_6') on duplicate key update uid=values(uid),`name`=values(`name`),sign=values(sign),img=values(img),gender=values(gender),area_code=values(area_code),phone=values(phone),update_time=values(update_time),cache_key=values(cache_key);"
	req.DatabaseId = "database_1"
	var ret, err = app.SendSqlExecute(&req, &rsp)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Printf("ret: %d, rsp: %+v\n", ret, rsp)
}
